home *** CD-ROM | disk | FTP | other *** search
/ Gigarom 1 / Gigarom Macintosh Archives (Quantum Leap)(CDRM1080320)(1993).iso / FILES / DEM / I-M / LineShare DEMO.sea / LineShare Scripts / EXAR Fax&Hermes < prev    next >
Text File  |  1992-12-25  |  6KB  |  302 lines

  1. !
  2. ! LineShare™ Script for 2400/9600 data-fax modems (EXAR-based)
  3. !
  4. ! If you want to modify this script for your modem, pay attention to
  5. ! the line marked "#### Settings ####" - it should be modified first
  6. ! This script is written to use with the Hermes™ BBS on the "Hermes" subPort:
  7. ! this application sets the modem into the "V0" mode.
  8. ! This script doesn't set the "V0" mode, but instead - translates all CONNECT
  9. ! messages into their numeric values
  10. ! This trick is marked with the "$$$" symbols
  11. !
  12. ! ------------------------------------------
  13. ! Resetting the modem:
  14. ! ------------------------------------------
  15. @Hangup
  16.   SetTries 2
  17.   Flush
  18.   HsReset 0,0,17,19,0,0
  19. !
  20. ! Try to catch the "OK" answer, use the Escape seq and DTR transitions
  21. ! to enter the command mode
  22. !
  23. @Label 1
  24.   matchclr
  25.   matchstr 1 2 "OK\r\n"
  26.   write "ATH0&F\r"
  27.   matchread 20
  28.   Write "+++"
  29.   DtrClear
  30.   pause 10
  31.   DtrSet
  32. !
  33.   DecTries
  34.   IfTries 0 1
  35. !
  36. ! OSErr -6019 "Modem error - the modem is not responding"
  37. !
  38.   exit -6019
  39. @Label 2
  40.   write "AT+FCLASS=0\r"
  41.   Jsr 100
  42.   write "AT+FAA=0\r"
  43.   Jsr 100
  44.   exit 0
  45. ! ------------------------------------------
  46. !    Receiving incoming calls
  47. ! ------------------------------------------
  48. @ANSWER
  49. @Label 10
  50. !
  51. ! Set the modem preferred speed first
  52. !
  53.   SERRESET 2400,0,8,1
  54.   Jsr 80
  55. !
  56. ! Set the common options
  57.   Jsr 70
  58. !
  59. ! Set the communication options:
  60. ! • Extended response set
  61. ! • Enable MNP connections (for Hermes)
  62. ! • Xon/Xoff flow control (for Fax)
  63. ! • &S1 -  according to CCITT (if the cable connects CTS with DSR, not DCD)
  64. !
  65. @Label 11
  66. ! #### Settings - change this according to the type of modem you have ####
  67.   Write "ATX4\\N3\\Q1&S1\r"
  68.   Jsr 100
  69. !
  70. ! Set the "work" speed
  71. !
  72. @Label 12
  73.   SERRESET 19200,0,8,1
  74.   Jsr 80
  75. !
  76. ! Set Fax parameters: LID, DCC,BOR
  77. !
  78.   Write "AT+FCLASS=2\r"
  79.   Jsr 100
  80.   Write "AT+FLID=\"Stalker_GmbH\"\r"
  81.   Jsr 100
  82.   Write "AT+FDCC=1,3,0,2,0,0,0,0\r"
  83.   Jsr 100
  84.   Write "AT+FBOR=1\r"
  85.   Jsr 100
  86. !
  87. ! Allow modem to receive fax messages
  88. !
  89.   Write "AT+FCR=1\r"
  90.   Jsr 100
  91. !
  92. ! Tell the modem to determine the type of the incoming call
  93. ! Fetch the tube after N rings, where N has been set in the control panel (^4)
  94. !
  95.   Write "ATS0=^4+FAA=1\r"
  96.   Jsr 100
  97. !
  98. ! Everything is ready - let's sit and wait for a call
  99. ! We'll wait for 2 minutes, then reinitiate the modem
  100. !
  101. @Label 20
  102.   MatchClr
  103.   matchstr 1  20 "RING\r\n"
  104.   matchstr 2  30 "\r\n+FCON"
  105.   matchstr 3  10 "\r\nNO "
  106.   matchstr 4  10 "\r\nBUSY"
  107.   matchstr 5  21 "\r\nCONNECT 1200"
  108.   matchstr 6  22 "\r\nCONNECT 2400"
  109.   matchstr 7  23 "\r\nCONNECT 4800"
  110.   matchstr 8  24 "\r\nCONNECT 9600"
  111.   matchstr 9  25 "\r\nCONNECT 14400"
  112.   matchstr 10 26 "\r\nCONNECT 19200"
  113.  
  114.   Matchread 1200
  115.   jump 10
  116. !
  117. ! Data connection has been established (we read "CONNECT")
  118. ! $$$
  119. ! $$$ Put the numeric response back to the buffer and attach the "Data" subPort
  120. ! $$$ Since we didn't use \N1, we don't adjust the port speed
  121. ! $$$ (make sure that your BBS is prepeared to work in this mode
  122. @Label 21
  123.   jsr 28
  124.   QueueInput "5\r"
  125.   Jump 27
  126. @Label 22
  127.   jsr 28
  128.   QueueInput "10\r"
  129.   Jump 27
  130. @Label 23
  131.   jsr 28
  132.   QueueInput "11\r"
  133.   Jump 27
  134. @Label 24
  135.   jsr 28
  136.   QueueInput "12\r"
  137.   Jump 27
  138. @Label 25
  139.   jsr 28
  140.   QueueInput "13\r"
  141.   Jump 27
  142. @Label 26
  143.   jsr 28
  144.   QueueInput "14\r"
  145. @Label 27
  146.   Attach "Hermes" (DTR,BREAK,Escape,IDLELimit=60)
  147. !
  148. ! This routine clears the input buffer (after the CONNECT) till "\r\n"
  149. !
  150. @Label 28
  151.   MatchClr
  152.   MatchStr 1 29 "\r\n"
  153.   MatchRead 10
  154. @Label 29
  155.   return
  156.  
  157. !
  158. ! Fax connection has been established (we read "+FCON")
  159. ! Put the +FCON back to the buffer,
  160. ! if it was an incoming call, put the "RING" before the "+FCON"
  161. ! Attach the "Fax" subPort
  162. !
  163. @Label 30
  164.   QueueInput "\r\n+FCON"
  165.   ifOriginate 31
  166.   QueueInput "\r\nRING\r\n"
  167. @Label 31
  168.   Attach "Fax" (DTR,RESET,ESCAPE,IDLELimit=30)
  169. ! ------------------------------------------
  170. ! Originating a call through the "Hermes" subport
  171. ! ------------------------------------------
  172. @ORIGINATE "Hermes"
  173. !
  174. ! Set the Data speed
  175. !
  176.   SERRESET 2400,0,8,1
  177.   Jsr 80
  178. !
  179. ! Set the common options
  180. !
  181.   Jsr 70
  182. !
  183. ! Set the Data mode
  184. ! S7 is set to 1.5 minute for international calls
  185. ! &S1 should be set if necessary (see above) 
  186. !
  187.   Write "ATS7=90&S1+FCLASS=0\r"
  188.   Jsr 100
  189. !
  190. ! Now emit all commands that the application has sent to that port
  191. !
  192.   Jsr 60
  193. !
  194. ! Prepare to receive all error result codes
  195. !
  196.   Jsr 90
  197.   matchstr 1 21 "\r\nCONNECT"
  198. !
  199. ! Dial the number
  200. !
  201.   HsReset *
  202.   Write "ATD^1\r"
  203.   MatchRead 900
  204.   Write "\r"
  205.   Exit -6019
  206. ! ------------------------------------------
  207. ! Originating a call through the "Fax" subPort
  208. ! ------------------------------------------
  209. @ORIGINATE "Fax"
  210. !
  211. ! Set the "Fax" speed
  212. !
  213.   SERRESET 19200,0,8,1
  214.   Jsr 80
  215. !
  216. ! Set the common options
  217. !
  218.   Jsr 70
  219. !
  220. ! Set the Fax mode
  221. ! &S0: DSR always on (see above)
  222. !
  223.   Write "AT&S0+FCLASS=2\r"
  224.   Jsr 100
  225. !
  226. ! Now emit all commands that the application has sent to that port,
  227. ! Prepare to receive all error result codes
  228. !
  229. @LABEL 50
  230.   Jsr 60
  231.   Jsr 90
  232.   MatchStr 1 30 "\r\n+FCON"
  233.   HsReset *
  234.   Write "ATD^1\r"
  235.   MatchRead 700
  236.   Write "\r"
  237.   Exit -6019
  238. !
  239. ! This section emits all modem commands sent from the client application
  240. ! For each set of commands the "OK" answer is awaited
  241. !
  242. @Label 60
  243.   EmitStart
  244. @Label 61
  245.   EmitCommand 62
  246.   Jsr 100
  247.   Jump 61
  248. @Label 62
  249.   return
  250. !
  251. ! This section initiates the modem before ANSWER and ORIGINATEs:
  252. ! factory settings + speaker control +
  253. ! reset on Dtr drop + DCD valid
  254. ! Verbal responses mode, no echo 
  255. !
  256. @Label 70
  257.   Write "ATM^2L^3&D3&C1V1E0\r"
  258.   Jsr 100
  259.   return 
  260. !
  261. ! This section syncronize the modem after the serial port speed switching
  262. !
  263. @Label 80
  264.   ChrDelay 1
  265.   Write "AT\r"
  266.   ChrDelay 0
  267.   Jsr 100
  268.   return
  269. !
  270. ! Prepare to receive error result codes
  271. !
  272. @Label 90
  273.   MatchClr
  274.   MatchStr 2 91 "NO DIALTONE\r\n"
  275.   MatchStr 3 92 "BUSY\r\n"
  276.   MatchStr 4 93 "NO CARRIER\r\n"
  277.   MatchStr 5 94 "NO ANSWER\r\n"
  278.   return
  279. @Label 91
  280.   exit -6020
  281. @Label 92
  282.   exit -6022
  283. @Label 93
  284.   exit -6021
  285. @Label 94
  286.   exit -6023
  287. !
  288. ! Processing the AT command:
  289. ! OK -> proceed
  290. ! ERROR or TimeOut ->exit -6019
  291. ! It can be called AFTER the "Write" command, since LineShare buffers input
  292. !
  293. @Label 100
  294.   MatchClr
  295.   MatchStr 1 102 "\r\nOK\r\n"
  296.   MatchStr 2 101 "\r\nERROR\r\n"
  297.   MatchRead 20
  298. @Label 101
  299.   Exit -6019
  300. @Label 102
  301.   return
  302.